<?php
//-------------------------------------------------------------------------------------------------------
    require_once($config['app_dir'] . '/classes/user.class.php');
    require_once($config['app_dir'] . '/classes/contacts.class.php');
    require_once($config['app_dir'] . '/classes/class.payment.php');
    require_once($config['app_dir'] . '/classes/admin.user.class.php');
    require_once($config['app_dir'] . '/classes/news.class.php');
    //---------------------------------------------------------------------------------------------------
    class objMenu {
            public $public_root = '';
            protected $_page_name = false;
            protected $_main_menu = false;
            protected $_sub_menu = false;
			protected $_main_menu_captions =
				array (// 'main menu item' => 'main menu caption'
					'about'=>'About Us', //1
					'forecasts'=>'Forex Forecasts', //2
					'perf'=>'Performance', //3
					'rates'=>'Subscribe', //4
					'tech'=>'Technology', //5
//					'faq'=>'FAQ', //6
					'contacts'=>'Contact Us'//7
					);

//based on main menu
			protected $_left_menu_header =
				array (//0 'main menu item' => 'left menu header'
					'home' => '&nbsp;',
					'about'=>'Recent Forecasts',
					'forecasts'=>'&nbsp;',
					'perf'=>'&nbsp;',
					'rates'=>'Recent Forecasts',
					'tech'=>'Recent Forecasts',
					'faq'=>'FAQ',
					'contacts'=>'&nbsp;',
					'none'=>'&nbsp;',
					'userstats'=>'&nbsp;'
					);

			protected $_left_menu_templates =
				array (//0 'page_name' => 'left menu template'
					'home' => 'empty.tpl',
					'about'=>'menus/menu_about.tpl',
					'forecasts'=>'menus/menu_forecasts.tpl',
					'perf'=>'menus/menu_performance.tpl',
					'rates'=>'menus/menu_rates.tpl',
					'tech'=>'menus/menu_technology.tpl',
					'faq'=>'menus/menu_faq.tpl',
					'contacts'=>'_trial.tpl',
					'userstats'=>'empty.tpl'

					);
			protected $_is_left =
				array (//0 'page_name' => '0|1'
					'home' => '1',
					'about'=>'1',
					'forecasts'=>'1',
					'perf'=>'1',
					'rates'=>'1',
					'tech'=>'1',
					'faq'=>'1',
					'contacts'=>'1',
					'none'=>'1'
					);

//based on page
			protected $_is_right =
				array (//0 'page_name' => '0|1'
					'home' => '0'
					);
			protected $_right_source_templates =
				array (//0 'page_name' => 'right source template'
					'home' => 'empty.tpl',
					'about'=>'empty.tpl',
					'forecasts'=>'empty.tpl',
					'perf'=>'empty.tpl',
					'rates'=>'empty.tpl',
					'tech'=>'empty.tpl',
					'faq'=>'empty.tpl',
					'contacts'=>'empty.tpl',
					'confirm'=>'empty.tpl',
					'userstats'=>'empty.tpl'
					);


			protected $_main_menu_items =
				array (
					'confirm'=>'forecasts',
					'remind' => 'none',
					'map'=>'none',

					'home' => 'home', //0 'page_name' => 'main menu item'
					'about'=>'about', //1
					'forecasts'=>'forecasts', //2
					'perf'=>'perf', //3
					'rates'=>'rates', //4
					'tech'=>'tech', //5
					'faq'=>'faq', //6
					'contacts'=>'contacts',//7
					'userstats'=>'userstats'//7
					);

			protected $_headers =
				array (// 'page_name' => 'header'
					'confirm'=>'Account Activated Successfully',
					'remind' => 'Password Assistance',
					'map' => 'Site Map',

					'home' => 'IntelliForex - Forex Forecasts, Charts and Trade Signal Alerts',
					'about'=>'About Us',
					'forecasts'=>'Forex Forecasts',
					'userstats'=>'Forex Forecasts Subscription',
					'perf'=>'Performance',
					'rates'=>' Register for Free 14-Day Trial', //'Rates & Sign Up - Subscribe',
//					'register'=>'Free Trial - Registered Successfully',
					'tech'=>'Technology',
					'faq'=>'FAQ', //Frequently Asked Questions',
					'contacts'=>'Contact Us',
					'userstats'=>'User Statistics'//7
					);
			protected $_titles =
				array (// 'page_name' => 'title'
					'confirm'=>'Forex Forecast - Forex Forecasting and Forex forecast services // IntelliForex',
					'remind' => 'Forex Forecast - Forex Trade Signal Alerts - Forex Trading Advice // IntelliForex',
					'map' => 'Forex Forecast - Forex Trade Signal Alerts - Forex Trading Advice // IntelliForex',

					'home' => 'Forex Forecast - Forex Trade Signal Alerts - Forex Trading Advice // IntelliForex',
					'about'=>'About - IntelliForex // Forex Forecast - Forex Trade Signal Alerts - Forex Trading Advice',
					'forecasts'=>'Forex Forecast - Forex Forecasting and Forex forecast services // IntelliForex',
					'userstats'=>'Forex Forecasts Subscription',
					'perf'=>'Forex Signals Performance - Forex Trading Signals Performance History // IntelliForex',
					'rates'=>'Forex Subscription Service  - Rates & Sign Up - Subscribe // IntelliForex',
//					'register'=>'Free Trial - Registered Successfully',
					'tech'=>'Technology - IntelliForex // Forex Forecast - Forex Trade Signal Alerts - Forex Trading Advice',
					'faq'=>'FAQ - IntelliForex - Frequently Asked Questions // Forex Forecast - Forex Trade Signal Alerts',
					'contacts'=>'Contact Us - IntelliForex // Forex Forecast - Forex Trade Signal Alerts - Forex Trading Advice'
					);
			protected $_keywords =
				array (// 'page_name' => 'keywords'
					'confirm'=>'forex forecasts, forex forecasting, fx, exchange, currency, forecast, forex, alerts, 4x, analysis, advisor, trading alerts, advisory',
					'remind' => 'forex forecasts, forex alert, exchange, currency, forex signals, alerts, 4x, analysis, trading signal, forex, forecast, trading alerts, advisor, forecasting, advisory, fx',
					'map' => 'forex forecasts, forex alert, exchange, currency, forex signals, alerts, 4x, analysis, trading signal, forex, forecast, trading alerts, advisor, forecasting, advisory, fx',

					'home' => 'forex forecasts, forex alert, exchange, currency, forex signals, alerts, 4x, analysis, trading signal, forex, forecast, trading alerts, advisor, forecasting, advisory, fx',
					'about'=>'about, forex forecasts, forex alert, forex signals, exchange, currency, alerts, 4x, analysis, trading signal, forex, forecast, trading alerts, advisor, forecasting, advisory',
					'forecasts'=>'forex forecasts, forex forecasting, fx, exchange, currency, forecast, forex, alerts, 4x, analysis, advisor, trading alerts, advisory',
					'userstats'=>'Forex Forecasts Subscription',
					'perf'=>'performance, forex forecasts, forex alert, exchange, currency, forex signals, alerts, 4x, analysis, trading signal, forex, forecast, trading alerts, advisor, forecasting, advisory',
					'rates'=>'forex rate, rates, forex forecasts, forex alert, subscribe, exchange, currency, forex signals, alerts, 4x, analysis, trading signal, forex, forecast, trading alerts, advisor, forecasting, advisory, fx',
//					'register'=>'Free Trial - Registered Successfully',
					'tech'=>'technology, forex subscription, forex forecasts, alert, exchange, currency, forex signals, alerts, 4x, analysis, trading signal, forex, forecast, trading alerts, advisor, forecasting, advisory, fx',
					'faq'=>'faq, forex forecasts, forex alert, frequently asked questions, exchange, currency, forex signals, alerts, 4x, analysis, trading signal, forex, forecast, trading alerts, advisor, forecasting, advisory, fx',
					'contacts'=>'contact us, forex forecasts, forex alert, contact information, exchange, currency, forex signals, alerts, 4x, analysis, trading signal, forex, forecast, trading alerts, advisor, forecasting, advisory, fx'
					);
			protected $_descriptions =
				array (// 'page_name' => 'title'
					'confirm'=>'Forex forecasts and alerts. Forex forecast currency predictions for traders. Forex forecasting and forex forecast services. Forex forecast analysis with forex forecast data and forex forecast service.',
					'remind' => 'Forex forecasts, alerts and technical analysis. Forex alerts and forex forecast currency predictions for traders. Forex forecast analysis with forex forecast data and forex forecast service.',
					'map' => 'Forex forecasts, alerts and technical analysis. Forex alerts and forex forecast currency predictions for traders. Forex forecast analysis with forex forecast data and forex forecast service.',

					'home' => 'Forex forecasts, alerts and technical analysis. Forex alerts and forex forecast currency predictions for traders. Forex forecast analysis with forex forecast data and forex forecast service.',
					'about'=>'About IntelliForex. Intelli4x is forex forecast software that allows Forex traders place their orders more effectively by providing real-time market forecast.',
					'forecasts'=>'Forex forecasts and alerts. Forex forecast currency predictions for traders. Forex forecasting and forex forecast services. Forex forecast analysis with forex forecast data and forex forecast service.',
					'userstats'=>'Forex Forecasts Subscription',
					'perf'=>'Forex trading signals performance history and currencies performance charts. Forex performance foreign exchange forecasting.',
					'rates'=>'Forex Subscription Service. Forex Rates and Sign Up for forex alerts and forex forecast currency predictions.',
//					'register'=>'Free Trial - Registered Successfully',
					'tech'=>'Forex forecasts, alerts and technical analysis. Forex alerts and forex forecast currency predictions for traders.',
					'faq'=>'FAQ Intelli Forex - Frequently Asked Questions. Forex forecasts, alerts and technical analysis. Forex alerts and forex forecast currency predictions for traders.',
					'contacts'=>'Contact Us Intelli Forex - Contact information. Forex forecasts, alerts and technical analysis. Forex alerts and forex forecast currency predictions for traders.'
					);


        public function __construct($m, $s=false) {
			if('' == $m) $m = 'home';
//			print ($m);
			$this->_page_name = $m;
            $this->_main_menu = $this->_main_menu_items[$m];
//			foreach($this->_legend_titles as $color => $title)
            $this->_sub_menu = $s;
        } //constructor

	    function getTitle()
		{
			return $this->_titles[$this->_page_name];
		}
		function getKeywords()
		{
			return $this->_keywords[$this->_page_name];
		}
		function getDescription()
		{
			return $this->_descriptions[$this->_page_name];
		}

		function getHeader()
		{
			return $this->_headers[$this->_page_name];
		}

		function getMenuLeftHeader()
		{
			return $this->_left_menu_header[$this->_main_menu];
		}
		function getIsLeft()
		{
			return $this->_is_left[$this->_main_menu];
		}
		function getContentLeft()
		{
			global $Staff;
			$Template = new objTemplate();
			$Template->Assign_by_ref('Staff', $Staff);
			return $Template->Fetch($this->_left_menu_templates[$this->_main_menu]);
		}

		function getIsRight()
		{
			return $this->_is_right[$this->_page_name];
		}
		function getContentRight()
		{
			$Template = new objTemplate();
			return $Template->Fetch($this->_right_source_templates[$this->_page_name]);
		}

		function getMenuTop()
		{
			$menu_items = '';
			foreach($this->_main_menu_captions as $item=>$caption)
			{
				$Template = new objTemplate();
				$Template->Assign('item', $item);
				$Template->Assign('caption', $caption);
				$Template->Assign('link', 'index.php?p='.$item);
				if($this->_main_menu == $item)
					$Template->Assign('class', 'active');
				else
					$Template->Assign('class', 'noactive');

				$menu_items .= $Template->Fetch('menus/menu_top_item.tpl');
			}
			$Template = new objTemplate();
			$Template->Assign('menu_items', $menu_items);
			return $Template->Fetch('menus/menu_top.tpl');
		}

        public function getContent() {
          global $Staff, $config;
            $content = '';
            $Template = new objTemplate();
            switch( $this->_page_name )
            {
				//----------------------------------------------------------------------
				case "tech":
                    $content .= $Template->Fetch('texts/_technology.tpl');
					break;
				//----------------------------------------------------------------------
				case "faq":
                    $content .= $Template->Fetch('texts/_faq.tpl');
					break;
		        //----------------------------------------------------------------------
                case "perf":
                    $content .= $Template->Fetch('texts/_performance.tpl');
                break;
                //----------------------------------------------------------------------
                case "about":
                    switch( $this->_sub_menu )
                    {
                        case "team":
                            $content .= $Template->Fetch('texts/_about_team.tpl');
                        break;
                        //--------------------------------------------------------------
                        case "partners":
                            $content .= $Template->Fetch('texts/_about_partners.tpl');
                        break;
                        //--------------------------------------------------------------
                        case "about":
                        default:
                            $content .= $Template->Fetch('texts/_about_company.tpl');
                    }
                break;
        	//----------------------------------------------------------------------
                case "rates":
                	if ( !$Staff->Login() ) {
	                    $UserSignUp = new objUserSignUp();
						$UserSignUp->public_root = /*$this->public_root;*/$config['host']['root'];
	                    $content .= $UserSignUp->Render();
	                }
	                else {
	                	require_once("../classes/subscription.php"); //subscription logic
                    	$Template->Assign_by_ref('Staff', $Staff);
                    	$content .= $Template->Fetch('_subscriptions.tpl');
	                }
                break;
                //----------------------------------------------------------------------
                case "forecasts":
                    $Template->Assign_by_ref('Staff', $Staff);
                    $content .= $Template->Fetch('texts/_sec_forecasts.tpl');
				break;
                //----------------------------------------------------------------------
                case "settings":
                    if ( !$Staff->Login() ) echo 'Please register';
                    else {
                        $UserProfile = new objUserProfile();
                        $UserProfile->id = $Staff->UserID();
                        $content .= $UserProfile->Render();
                    }
                break;
                //----------------------------------------------------------------------
                case "subscribe":
                	if ( $Staff->Login() ) {
                		require_once("../classes/subscription.php"); //subscription logic
                	}
                    $Template->Assign_by_ref('Staff', $Staff);
                    $content .= $Template->Fetch('_subscriptions.tpl');
                break;
                //----------------------------------------------------------------------
                case "confirm":
                    $UserConfirm = new objUserConfirm($Staff);
                    $content .= $UserConfirm->Render();
                break;
                //----------------------------------------------------------------------
                case "remind":
                    $content .= $Template->Fetch('_form_remind_password.tpl');
                break;
                //----------------------------------------------------------------------
                case "contacts":
                    $Contacts = new objContactsDlg();
                    $content .= $Contacts->Render();
		    		$content .= $Contacts->ErrorStr();
                break;

               case "userstats":
               				//echo $Staff->UserGroup();
                        if($Staff->Login() && $Staff->UserGroup()=='Administrator'){
		               		$userAdmin = new objUserAdmin();
		               		if (isset($_POST['process'])){
		               			$userAdmin->sendNotifications();
		               			$Template->Assign('test', $userAdmin->getUsers2Notify());
		               		}
		               		$userAdmin->ProcessAction();
		               		$Template->Assign_by_ref('userAdmin', $userAdmin);
		               		$Template->Assign_by_ref('Staff', $Staff);
		               		$Template->Assign('refresher', time());
		                    $content .= $Template->Fetch('admin/userStats.tpl');
                        } else

                        exit;
				break;

				case "2w":
               				//echo $Staff->UserGroup();
                        if($Staff->Login() && $Staff->UserGroup()=='Administrator'){
		               		$userAdmin = new objUserAdmin();
		               		if (isset($_POST['process'])){
		               			$userAdmin->sendNotifications();
		               			$Template->Assign('test', $userAdmin->getUsers2Notify());
		               		}
		               		$userAdmin->ProcessAction();
		               		$Template->Assign_by_ref('userAdmin', $userAdmin);
		               		$Template->Assign_by_ref('Staff', $Staff);
		               		$Template->Assign('refresher', time());
		                    $content .= $Template->Fetch('admin/user2w.tpl');
                        } else exit;
				break;

				case "usertotals":
               				//echo $Staff->UserGroup();
                        if($Staff->Login() && $Staff->UserGroup()=='Administrator'){
		               		$userAdmin = new objUserAdmin();
		               		if (isset($_POST['process'])){
		               			$userAdmin->sendNotifications();
		               			$Template->Assign('test', $userAdmin->getUsers2Notify());
		               		}
		               		$userAdmin->ProcessAction();
		               		$Template->Assign_by_ref('userAdmin', $userAdmin);
		               		$Template->Assign_by_ref('Staff', $Staff);
		               		$Template->Assign('refresher', time());
		                    $content .= $Template->Fetch('admin/userTotals.tpl');
                        } else exit;
				break;

				case "userregs":
               				//echo $Staff->UserGroup();
                        if($Staff->Login() && $Staff->UserGroup()=='Administrator'){
		               		$userAdmin = new objMonthTrial();
		               		$Template->Assign('trials', $userAdmin->getUsersTrials());
		                    $content .= $Template->Fetch('admin/userRegistrations.tpl');
                        } else

                        exit;
				break;

				case "trialists":
               				//echo $Staff->UserGroup();
                        if($Staff->Login() && $Staff->UserGroup()=='Administrator'){
		               		$userAdmin = new objTrialUsers();
		               		$resetArray = $userAdmin->getTrialsUsers();
		               		$Template->Assign('trialists', $userAdmin->getTrialsUsers());
		               		$Template->Assign_by_ref('userAdmin', $userAdmin);
		                    $content .= $Template->Fetch('admin/trialists.tpl');
                        } else exit;
				break;

				case "addmap":
               				//echo $Staff->UserGroup();
                        if($Staff->Login() && $Staff->UserGroup()=='Administrator'){
		               		$map = new objAddMAP();
		               		$map->addMAPrecord();

		               		$Template->Assign('systems', $map->getSystems());
		                    $content .= $Template->Fetch('admin/addMAP.tpl');
                        } else exit;
				break;

				case "cheeters":
                        if($Staff->Login() && $Staff->UserGroup()=='Administrator'){
                        	//error_reporting('E_ALL');

		               		$tracker = new objUserTracker();
		               		$tracker->getCheeterData();

		               		$Template->Assign('cheeters', $tracker->cheetersData);
		               		$Template->Assign('test', count($tracker->cheetersData));
		                    $content .= $Template->Fetch('admin/userCheet.tpl');
                        } else exit;
				break;

				case "iplist":
                        if($Staff->Login() && $Staff->UserGroup()=='Administrator'){

                        	//error_reporting('E_ALL');

		               		$tracker = new objUserTracker();
		               		$Template->Assign('users', $tracker->getIPData());
		                    $content .= $Template->Fetch('admin/userIP.tpl');
                        } else exit;
				break;

				case "discounts":
               				//echo $Staff->UserGroup();
                        if($Staff->Login() && $Staff->UserGroup()=='Administrator'){
		               		$objDiscount = new objDiscount();
		               		if (isset($_POST['process'])){                    			$objDiscount->insertDiscounts($_POST['prefix'],$_POST['dsct_size'],array($_POST['rangeStart'],$_POST['rangeEnd']));
		               		}

		               		//$Template->Assign_by_ref('userAdmin', $userAdmin);
		               		//$Template->Assign_by_ref('Staff', $Staff);
		               		//$Template->Assign('refresher', time());
		                    $content .= $Template->Fetch('admin/discounts.tpl');
                        } else

                        exit;
				break;
                //----------------------------------------------------------------------
				case "map":
                    $content .= $Template->Fetch('menus/_site_map.tpl');
				break;
                default:
					$content .= $Template->Fetch('texts/_error404.tpl');
                //----------------------------------------------------------------------
            }
            return $content;
        } //run
    } //class Menu
//-------------------------------------------------------------------------------------------------------
?>